<!DOCTYPE html>
	<html>
	<head>
	<meta charset="utf-8">
	<title>菜鸟教程(runoob.com)</title>
	</head>
	<body>
	




		<div id="logos">
			<button onclick="changess()">点击</button>
			  <img src="" class="qrcode" alt="二维码展示"/>
			
			</div>
			<script type="text/javascript" src="__ROOT__/static/js/jquery.min.js"></script>
			<script type="text/javascript">
			
			  function changess()
			  {
				  console.log("dfsdfsbf");
				 var logos = document.getElementById ('logos');
				$.ajax({
						 type: "GET",
						 url: "../../../index/Index/index6",
						// data: '',
						data:{},
						 dataType: "json",
						 success: function(r){
							 console.log("fdfdffsdJNFKDSNFSDFK")
									if (r.code==200) { //console.log(r); 
									var path = 'data:image/png;base64,'+r.data; //给img的sec赋值。
									console.log(path);
									 $("#logos").html("<img src="+path+">");
									
									 logos.html("<img src="+path+">");
									 console.log( logos.html("<img src="+path+">"));
								   }else{
										alert(r.err); 
									  }
								  }
					 });
			  }
			</script>

<h4>页面代码</h4>
	{literal}
	<pre>
	&lt;div id="logos">
	&lt;button onclick="changess()">点击&lt;/button>
		&lt;img src="" class="qrcode" alt="二维码展示"/>
	
	&lt;/div>
	&lt;script type="text/javascript" src="__ROOT__/static/js/jquery.min.js">&lt;/script>
	&lt;script type="text/javascript">
	function changess()
	{
		console.log("dfsdfsbf");
	 var logos = document.getElementById ('logos');
	$.ajax({
			 type: "GET",
			 url: "../../../index/Index/index6",
			// data: '',
			data:{},
			 dataType: "json",
			 success: function(r){
				 console.log("fdfdffsdJNFKDSNFSDFK")
						if (r.code==200) { //console.log(r); 
						var path = 'data:image/png;base64,'+r.data; //给img的sec赋值。
						console.log(path);
						 $("#logos").html("<img src="+path+">");
						
						 logos.html("<img src="+path+">");
						 console.log( logos.html("<img src="+path+">"));
						 }else{
							alert(r.err); 
							}
						}
		 });
	}
	&lt;/script>
<h5>注</h5>
url: "../../../note.php/index/Index/index6", 在 http://www.hyhthjk.com.cn/note.php/index/Index/index5时可用
但在地址栏携带参数时就不可用 显示多了一个note.php
需要改成 url: "../../../index/Index/index6",		

<hr/>
<h4>后台代码</h4>
//第三方类库在 vendor/anli/phpqrcode
Vendor('anli.phpqrcode');
//QRcode 是phpqrcode 里的一个类
	$mod = new \QRcode;
	$url = "http://www.hyhthjk.com.cn/stock.php/index/Zixuan/index";
   $value = $url;         //二维码内容
   $errorCorrectionLevel = 'H';  //容错级别
   $matrixPointSize = 5;      //生成图片大小
	 ob_start();
	 // 原文是 $mod::png 改为$mod->png(
   $mod->png($value,false , $errorCorrectionLevel, $matrixPointSize, 2);  
   // $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2); //这里就是把生成的图片流从缓冲区保存到内存对象上，使用base64_encode变成编码字符串，通过json返回给页面。
   $imageString = base64_encode(ob_get_contents()); //关闭缓冲区
   ob_end_clean(); //把生成的base64字符串返回给前端 
   $data = array( 'code'=>200, 'data'=>$imageString ); 
   return json($data);




</pre>
	{/literal} 

	</body>
	</html>